<?php

/**
*	个性签名
*		
*/	

//包含公共文件
include '../../common/common.php';

//接收post传值
//var_dump($_POST);
$content = trim($_POST['person_content']);
var_dump($content);

//判断个性签名是否为空
if (!$content) {

	exit('个性签名不得为空<br /> <a href="'  . $_SERVER['HTTP_REFERER'] .'">返回上一页</a>');
}

//获取用户名
$username = $_COOKIE['username'];

//比对数据库
$selPer = mySelect($link , '*' , DB_TABLE_USER , "username = '$username'");
$selAutograph = $selPer[0]['autograph'];
// var_dump($selAutograph);
if ($selAutograph == $content) {

	echo '当前内容未做修改';
} else {
	
	//修改数据库
	$data = ['autograph' => "$content"];
	$resText = myUpdate($link , DB_TABLE_USER , $data , "username = '$username'");
	// var_dump($resText);

	if ($resText && mysqli_affected_rows($link)) {

		echo '个性签名修改成功';
	} else {

		echo '个性签名尚未修改,请您进行修改,';
	}

}

//跳转到上一页
header('refresh:1;url=' . $_SERVER['HTTP_REFERER']);